﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using LunwenYun.Portal.WebLogic;
using LunwenYun.Portal.Web.Models;
using LunwenYun.Portal.Biz;
using LunwenYun.Infrastructure.Entities.Entity;
using LunwenYun.Infrastructure.Entities.Enum;
using System.IO;
using LunwenYun.Tool.Framework;

namespace LunwenYun.Portal.Web.Controllers
{
    [ErrorHandle]
    [Compress]
    public class HomeController : SiteBaseController
    {
        //
        // GET: /Home/

        public ActionResult Index(int ind = -1, int apt = -1, int lang = -1, string journalName = "", int page = 0)
        {
            ViewBag.IndType = ind;
            ViewBag.Aptitude = apt;
            ViewBag.Language = lang;
            ViewBag.JournalName = journalName;
            ViewBag.Data = new ItemListBox<Periodical>(SystemBiz.GetAllPeriodical(ind, -1, apt, lang, journalName, page, 15))
                .BuildPage(SystemBiz.GetAllPeriodicalForPage(ind, -1, apt, lang, journalName), page, 15,
                new PageParameter() { Style = "home" });
            return View();
        }

        public ActionResult forbidden()
        {
            return View();
        }
        public string getPeriodical(int ind, int subind, int apt, int lang)
        {
            List<Periodical> data = iCache.Get(String.Format("SystemBiz.GetAllPeriodical_{0}_{1}_{2}_{3}_{4}_{5}", ind, subind, apt, lang, 0, 6),
                () => { return SystemBiz.GetAllPeriodical(ind, subind, apt, lang,String.Empty, 0, 60); }, 1200);
            if (data != null)
            {
                return data.Select(c => new { Name = c.Name, Id = c.Id }).ToList().ToJson();
            }
            return "";
        }

        public ActionResult Agreement()
        {
            return View();
        }

        public ActionResult agentagreement()
        {
            return View();
        }

        public ActionResult setagentinfo()
        {
            return View();
        }

        public ActionResult error()
        {
            return View();
        }

        public ActionResult ConsumerService()
        {
            return View();
        }
    }
}
